const wx2my = require('../../../wx2my');
const Behavior = require('../../../Behavior');
var base = require('./../../../config.js');
var app = getApp();
Page({
  data: {
    imgUrl:''
  },
  onLoad: function (o) {
    var a = this;
    wx2my.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#ffffff'
    })
    a.setData({
      // color: wx2my.getStorageSync(["platform"]).data.color
    })
    console.log(o);
    var t = wx2my.getStorageSync(["imgUrl1"]).data,
        e = (o.hotel_id, o.room_id),
        n = (new Date().toLocaleDateString().replace(/\//g, "-"), o.coordinates),
        r = o.tel,
        i = o.address,
        s = o.name,
        c = o.price;
    a.setData({
      tel: r,
      coordinates: n,
      address: i,
      name: s,
      price: c,
      room_id: e,
      hotel_id: o.hotel_id
    }), 
    wx2my.newRequest({
      url: base.siteroot,
      data:{
        c:'entry',
        a:'wxapp',
        do:'RoomDetails',
        m:'zh_jdgjb',
        room_id:e
      },
      success: (res) => {
        console.log(res)
        res.data.img = res.data.img.split(","),
        a.setData({
          room: res.data,
          imgUrl: t
        });
      },
      fail: (err) => {
        console.log(err);
      }
    })
    // app.util.request({
    //   url: "entry/wxapp/RoomDetails",
    //   cachetime: "0",
    //   data: {
    //     room_id: e
    //   },
    //   success: function (o) {
    //     console.log("这是房型列表"), console.log(o), o.data.img = o.data.img.split(","), 
    //     a.setData({
    //       room: o.data,
    //       url: t
    //     });
    //   }
    // });
  },
  phone: function (o) {
    wx2my.makePhoneCall({
      phoneNumber: this.data.tel
    });
  },
  dizhi: function (o) {
    var a = this,
        t = Number(a.data.coordinates.split(",")[0]),
        e = Number(a.data.coordinates.split(",")[1]);
    wx2my.openLocation({
      latitude: t,
      longitude: e,
      name: a.data.name,
      address: a.data.address
    });
  },
  previewImage: function (o) {
    console.log(o);
    var a = this.data.imgUrl,
        t = [],
        e = o.currentTarget.dataset.index;
    console.log(e);
    var n = this.data.room.img;

    for (var r in n) t.push(a + n[r]);

    wx2my.previewImage({
      current: a + n[e],
      urls: t
    });
  },
  setclip: function (o) {
    wx2my.setClipboardData({
      data: "1.0版本",
      success: function (o) {
        wx2my.getClipboardData({
          success: function (o) {
            console.log(o.data);
          }
        });
      }
    });
  },
  formSubmit: function (t) {
    var e = this;
    var a = t.detail.formId;
    wx2my.navigateTo({
      url: "../place_order/place_order?room_id=" + e.data.room_id + "&hotel_id=" + e.data.hotel_id + "&form_d=" + a
    });
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {}
});